package cn.zhp.service.impl;

import cn.zhp.entity.SysOffice;
import cn.zhp.mapper.SysOfficeMapper;
import cn.zhp.service.SysOfficeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional

public class SysOfficeServiceImpl extends BaseServiceImpl<SysOffice> implements SysOfficeService {

    @Autowired
    private SysOfficeMapper sysOfficeMapper;


    /**
     * 根据角色id查询已授权机构  和所有机构信息
     * @param rid
     * @return
     */
    @Override
    public Map<String, List<SysOffice>> selectByRid(long rid){
        HashMap<String, List<SysOffice>> map = new HashMap<>();
        SysOffice sysOffice = new SysOffice();
        sysOffice.setDelFlag("0");
        map.put("all",sysOfficeMapper.select(sysOffice));
        map.put("offices",sysOfficeMapper.selectByRid(rid));

        return map;
    }


    /**
     * 模拟异常日志处理
     * @return
     */
    @Override
    public List<SysOffice> selectAll() {

        return super.selectAll();
    }
}
